<template>
    <view>
        <button
            :class="
                'custom-class theme-class zan-btn ' +
                (inGroup ? 'zan-btn--group' : '') +
                ' ' +
                (isLast ? 'zan-btn--last' : '') +
                ' ' +
                (size ? 'zan-btn--' + size : '') +
                ' ' +
                (size === 'mini' ? 'zan-btn--plain' : '') +
                ' ' +
                (plain ? 'zan-btn--plain' : '') +
                ' ' +
                (type ? 'zan-btn--' + type : '') +
                ' ' +
                (loading ? 'zan-btn--loading' : '') +
                ' ' +
                (disabled ? 'zan-btn--disabled' : '')
            "
            :disabled="disabled"
            hover-class="button-hover"
            :open-type="openType"
            :app-parameter="appParameter"
            :hover-stop-propagation="hoverStopPropagation"
            :hover-start-time="hoverStartTime"
            :hover-stay-time="hoverStayTime"
            :lang="lang"
            :session-from="sessionFrom"
            :send-message-title="sendMessageTitle"
            :send-message-path="sendMessagePath"
            :send-message-img="sendMessageImg"
            :show-message-card="showMessageCard"
            @tap="handleTap"
            @contact="bindcontact"
            @getuserinfo="bindgetuserinfo"
            @getphonenumber="bindgetphonenumber"
            @error="binderror"
            @opensetting="bindopensetting"
        >
            <slot></slot>
        </button>
    </view>
</template>

<script>
'use strict';

var nativeButtonBehavior = require('./native-button-behaviors');

export default {
    data() {
        return {
            inGroup: false,
            isLast: false,
            // openType: '',
            // appParameter: '',
            // hoverStopPropagation: 0,
            // hoverStartTime: '',
            // hoverStayTime: '',
            // lang: '',
            // sessionFrom: '',
            // sendMessageTitle: '',
            // sendMessagePath: '',
            // sendMessageImg: '',
            // showMessageCard: ''
        };
    },
    externalClasses: ['custom-class', 'theme-class'],
    mixins: [nativeButtonBehavior],
    relations: {
        '../btn-group/index': {
            type: 'parent',
            linked: function linked() {
                this.inGroup= true
            },
            unlinked: function unlinked() {
                this.inGroup= false
            }
        }
    },
    props: {
        type: {
            type: String,
            default: ''
        },
        size: {
            type: String,
            default: ''
        },
        plain: {
            type: Boolean,
            default: false
        },
        disabled: {
            type: Boolean,
            default: false
        },
        loading: {
            type: Boolean,
            default: false
        }
    },
    methods: {
        handleTap: function handleTap() {
            if (this.disabled) {
                this.$emit('disabledclick');
                return;
            }

            this.$emit('btnclick');
        },

        switchLastButtonStatus: function switchLastButtonStatus() {
            var isLast = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
            this.isLast= isLast
        },

        bindcontact() {
            console.log('占位：函数 bindcontact 未声明');
        },

        bindgetuserinfo() {
            console.log('占位：函数 bindgetuserinfo 未声明');
        },

        bindgetphonenumber() {
            console.log('占位：函数 bindgetphonenumber 未声明');
        },

        binderror() {
            console.log('占位：函数 binderror 未声明');
        },

        bindopensetting() {
            console.log('占位：函数 bindopensetting 未声明');
        }
    }
};
</script>
<style>
@import './index.css';
</style>
